package o;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;

public class foa extends fny {
    private boolean ˏ = false;
    private Activity ॱ;

    public foa(Activity activity, fnv o_fnv, foc o_foc) {
        super(o_fnv, o_foc);
        this.ॱ = activity;
    }

    public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
        super.onPageStarted(webView, str, bitmap);
        if (this.ˊ != null) {
            this.ˊ.ˊ(webView, str, bitmap);
        }
    }

    public void onPageFinished(WebView webView, String str) {
        super.onPageFinished(webView, str);
        if (this.ˊ != null) {
            this.ˊ.ˊ(webView, str);
        }
    }

    public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
        super.onReceivedError(webView, webResourceRequest, webResourceError);
        if (this.ˊ != null) {
            this.ˊ.ॱ(webView, webResourceError.getErrorCode(), webResourceError.getDescription().toString(), webResourceRequest.getUrl().toString());
        }
    }

    public void onReceivedError(WebView webView, int i, String str, String str2) {
        super.onReceivedError(webView, i, str, str2);
        if (this.ˊ != null) {
            this.ˊ.ॱ(webView, i, str, str2);
        }
    }

    @TargetApi(24)
    public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
        return ˊ(webResourceRequest.getUrl().toString());
    }

    public boolean shouldOverrideUrlLoading(WebView webView, String str) {
        if (this.ˊ != null) {
            this.ˊ.ˏ(webView, str);
        }
        return ˊ(str);
    }

    private boolean ˊ(String str) {
        if (!str.startsWith("sinaweibo://browser/close")) {
            return false;
        }
        Bundle ˊ = fnq.ˊ(str);
        if (!(this.ˋ.ˋ() == null || TextUtils.isEmpty(this.ˋ.ˋ().ˎ()))) {
            String ˎ = this.ˋ.ˋ().ˎ();
            fnu ˎ2 = fnu.ˎ();
            if (!(ˎ2.ˋ(ˎ) == null || ˊ.isEmpty())) {
                ˎ2.ॱ(ˎ);
            }
        }
        CharSequence string = ˊ.getString("code");
        String string2 = ˊ.getString("msg");
        if (TextUtils.isEmpty(string)) {
            ॱ(this.ॱ);
        } else if ("0".equals(string)) {
            ˋ(this.ॱ);
        } else {
            ॱ(this.ॱ, string2);
        }
        if (this.ˊ != null) {
            this.ˊ.ॱ();
        }
        return true;
    }

    private void ˏ(Activity activity, int i, String str) {
        fnm.ॱ("Share", "WebActivity.sendSdkResponse,errCode:" + i + ",errMsg:" + str);
        Bundle extras = activity.getIntent().getExtras();
        if (extras != null && !this.ˏ) {
            Intent intent = new Intent("com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY");
            String string = extras.getString("packageName");
            intent.setFlags(WXMediaMessage.MINI_PROGRAM__THUMB_LENGHT);
            intent.setPackage(string);
            intent.putExtras(extras);
            intent.putExtra("_weibo_appPackage", activity.getPackageName());
            intent.putExtra("_weibo_resp_errcode", i);
            intent.putExtra("_weibo_resp_errstr", str);
            try {
                activity.startActivityForResult(intent, 765);
            } catch (ActivityNotFoundException e) {
            }
            this.ˏ = true;
        }
    }

    public void ॱ(Activity activity) {
        ˏ(activity, 1, "send cancel!!!");
    }

    public void ˋ(Activity activity) {
        ˏ(activity, 0, "send ok!!!");
    }

    public void ॱ(Activity activity, String str) {
        ˏ(activity, 2, str);
    }

    public void ˊ(Activity activity, String str) {
        super.ˊ(activity, str);
        ॱ(activity, str);
    }

    public void ˏ() {
        super.ˏ();
        ॱ(this.ॱ);
    }

    public boolean ॱ() {
        ˏ();
        if (this.ˊ != null) {
            this.ˊ.ॱ();
        }
        return true;
    }
}
